﻿using System;
using System.IO;
using System.Reflection;
using Cqrs.Infrastructure;
using Cqrs.Infrastructure.Database;
using EventStore;
namespace DoorPanel
{
    class Program
    {
        static void Main(string[] args)
        {
            Repository<Door> _repository;
            // Replace this with the location of your .smf file:
            string _smfFile = @"C:\Users\Sean\Desktop\Thesis\cqrs-thesis-software\Door\Door.smf";
            IEventStore eventStore = new RavenDb(
                Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Db"),
                new EventPublisher());

            _repository = new Repository<Door>(eventStore);
            
            Guid doorId = Guid.NewGuid();
            int version = 0;
            DoorCommandHandlers _commandHandler = new DoorCommandHandlers(_repository, _smfFile);
            _commandHandler.Submit(new OpenDoor(doorId, DateTime.Now, version++));
            _commandHandler.Submit(new CloseDoor(doorId, DateTime.Now, version++));
            _commandHandler.Submit(new LockDoor(doorId, DateTime.Now, version++));
            _commandHandler.Submit(new CloseDoor(doorId, DateTime.Now, version++));
        }
    }
}
